$(function(){
  //get dom elem
  var $width=$('#width'),
      $height = $('#height'),
      $perimeter = $('#perimeter'),
      $area = $('#area'),
      $form = $('#main');

  function roundFractional(e, t) {
    return Math.round(e * Math.pow(10, t)) / Math.pow(10, t)                              
  }

  $form.submit((e)=>{
    e.preventDefault();
    //get value
    var w = Number($width.val()),
        h = Number($height.val());

    //cale
    var p = roundFractional((w + h)*2,2) ,
        a = roundFractional(w * h,2);

      //output
    $perimeter.val(p);
    $area.val(a);
  })

})


